package controller;

import model.*;
import ui.*;
import java.util.ArrayList;
public class CustomerCtr
{
        private CustomerContainer cc;
        
        public CustomerCtr()
        {
            cc = CustomerContainer.getInstance();
        }
        
        public boolean createCustomer(String name, String address, String phone, String groupName)
        {
            GroupContainer gc = GroupContainer.getInstance();
            Group g = gc.getGroup(groupName);
            if(g != null) {
                Customer c = new Customer(g, name, address, phone);
                CustomerContainer cc = CustomerContainer.getInstance();
                cc.addCustomer(c);
                return true;
            }
            else {
                    g = new Group("Default Group", 0, "Cash");
                    Customer c = new Customer(g, name, address, phone);
                    CustomerContainer cc = CustomerContainer.getInstance();
                    cc.addCustomer(c);
                return false;
            }
        }
        
        public ArrayList<Customer> findCustomer(String name)
        {
            CustomerContainer cc = CustomerContainer.getInstance();
            return cc.findCustomer(name);
        }
        
        public Customer getCustomer(String id)
        {
            CustomerContainer cc = CustomerContainer.getInstance();
            return cc.getCustomer(id);
        }
        
        public boolean updateCustomer(String id, String name, String address, String phone, String groupName)
        {
           // Not needed for this use case
           return false;
        }
        
        public boolean deleteCustomer(String name)
        {
           // Not needed for this use case
           return false;
        }
}